(function(){"use strict";BX.namespace("BX.Landing");var t=BX.Landing.Utils.debounce;var a=BX.Landing.Utils.data;var i=BX.Landing.Utils.proxy;var n=BX.Landing.Utils.onCustomEvent;var e=BX.Landing.Utils.encodeDataValue;BX.Landing.Block.Node.Map=function(t){BX.Landing.Block.Node.apply(this,arguments);this.type="map";this.attribute="data-map";this.hidden=true;this.createMap();this.lastValue=this.getValue();this.onBlockUpdateAttrs=this.onBlockUpdateAttrs.bind(this);n("BX.Landing.Block:Node:updateAttr",this.onBlockUpdateAttrs)};BX.Landing.Block.Node.Map.prototype={constructor:BX.Landing.Block.Node.Map,__proto__:BX.Landing.Block.Node.prototype,createMap:function(){this.mapOptions={mapContainer:this.node,mapOptions:a(this.node,"data-map"),theme:a(this.node,"data-map-theme"),roads:a(this.node,"data-map-roads")||[],landmarks:a(this.node,"data-map-landmarks")||[],labels:a(this.node,"data-map-labels")||[],onMapClick:i(this.onMapClick,this),onChange:t(this.onChange,500,this),fullscreenControl:false,mapTypeControl:false,zoomControl:false};this.map=BX.Landing.Provider.Map.create(this.node,this.mapOptions)},reinitMap:function(){const t=BX.Runtime.clone(this.mapOptions);this.mapOptions.mapOptions=a(this.node,"data-map");this.mapOptions.theme=a(this.node,"data-map-theme");this.mapOptions.roads=a(this.node,"data-map-roads")||[];this.mapOptions.landmarks=a(this.node,"data-map-landmarks")||[];this.mapOptions.labels=a(this.node,"data-map-labels")||[];if(t!==this.mapOptions){this.map.reinit(this.mapOptions)}},onBlockUpdateAttrs:function(t){if(t.node===this.node){this.reinitMap();this.lastValue=this.getValue()}},onMapClick:function(t){if(BX.Landing.UI.Panel.StylePanel.getInstance().isShown()){return}this.map.addMarker({latLng:this.map.getPointByEvent(t),title:"",description:"",showByDefault:false,draggable:true,editable:true});this.map.onMarkerClick(this.map.markers[this.map.markers.length-1])},onChange:function(t){if(this.isChanged()){if(!t){BX.Landing.History.getInstance().push()}this.lastValue=this.getValue();this.onChangeHandler(this,t)}},isChanged:function(){return JSON.stringify(this.getValue())!==JSON.stringify(this.lastValue)},getValue:function(){return this.map&&this.map.isApiLoaded()?this.map.getValue():null},getAttrValue:function(){return e(this.getValue())},setValue:function(t,a,i){this.map.setValue(t,i)},getField:function(){return new BX.Landing.UI.Field.BaseField({selector:this.selector,hidden:true})}}})();
//# sourceMappingURL=map.map.js